import request from '@/utils/request'
import {
    praseStrEmpty
} from '@/utils/ruoyi'

// 查询用户个人信息
export function getUserProfile() {
    return request({
        url: '/system/user/getInfo',
        method: 'get'
    })
}

// 获取默认的密码规则
export function getDeFaultPwdRule() {
    return request({
        url: '/system/pwdrule/getDeFaultPwdRule',
        method: 'get'
    })
}

// 编辑用户个人信息
export function updateUserProfile(data) {
    return request({
        url: '/system/user/updateProfile',
        method: 'post',
        data: data
    })
}

// 用户密码重置
export function updateUserPwd(data) {
    return request({
        url: '/system/user/updatePwd',
        method: 'post',
        data: data
    })
}

// 用户头像上传
export function uploadAvatar(data) {
    return request({
        url: '/system/user/profile/avatar',
        method: 'post',
        data: data
    })
}

//
// 密保问题列表:dictType的值等于"SYS_PWD_QUESTION_"
export function byDictType(data) {
    return request({
        url: '/system/dict/data/byDictType',
        method: 'get',
        params: data
    })
}

//这个接口是根据用户名，查询这个用户设置好的密保问题
export function querySecurityByUserName(data) {
    return request({
        url: '/system/findpwd/querySecurityByUserName',
        method: 'post',
        data: data
    })
}

export function queryQuestionByUserName(data) {
  return request({
    url: '/system/user/querySecurityByUserName',
    method: 'post',
    data: data
  })
}

//这个接口是根据用户名，查询这个用户设置好的密保答案
export function queryUserSecurity(data) {
    return request({
        url: '/system/user/queryUserSecurity',
        method: 'get',
        params: data
    })
}

//更新密保问题
export function updateUserPwdAnswer(data) {
    return request({
        url: '/system/user/updateUserPwdAnswer',
        method: 'post',
        data: data
    })
}

// 编辑手机号，往旧手机发
export function sendVerCodeForOldPhone(data) {
    return request({
        url: '/system/user/sendVerCodeForOldPhone',
        method: 'post',
        data: data
    })
}

// 编辑手机号，往现手机发
export function sendVerCodeForNewPhone(data) {
    return request({
        url: '/system/user/sendVerCodeForNewPhone',
        method: 'post',
        data: data
    })
}

// 编辑邮箱，往旧邮箱发
export function sendVerCodeForOldEmail(data) {
    return request({
        url: '/system/user/sendVerCodeForOldEmail',
        method: 'post',
        data: data
    })
}
export function checkUpdateUserInfo(data) {
    return request({
        url: '/system/user/checkUpdateUserInfo',
        method: 'post',
        data: data
    })
}


// 编辑邮箱，往现邮箱发
export function sendVerCodeForNewEmail(data) {
    return request({
        url: '/system/user/sendVerCodeForNewEmail',
        method: 'post',
        data: data
    })
}

// 校验消息验证码
export function checkVerCode(data) {
    return request({
        url: '/system/checkVerCode',
        method: 'post',
        data: data
    })
}

// 校验旧邮箱验证码
export function checkVerCodeForOldEmail(data) {
    return request({
        url: '/system/user/checkVerCodeForOldEmail',
        method: 'post',
        data: data
    })
}

// 校验新邮箱验证码
export function checkVerCodeForNewEmail(data) {
    return request({
        url: '/system/user/checkVerCodeForNewEmail',
        method: 'post',
        data: data
    })
}

// 校验旧邮箱验证码
export function checkVerCodeForOldPhone(data) {
    return request({
        url: '/system/user/checkVerCodeForOldPhone',
        method: 'post',
        data: data
    })
}

// 校验旧邮箱验证码
export function checkVerCodeForNewPhone(data) {
    return request({
        url: '/system/user/checkVerCodeForNewPhone',
        method: 'post',
        data: data
    })
}

//头像上传 只传userPic和userId属性
export function getUserPic(url) {
    return request({
        url: '/system/userAvatar',
        method: 'get',
        responseType: 'arrayBuffer',
        params: {
            avatarUrl: url
        }
    })
}

export function upLoadUserPic(data) {
    return request({
        url: '/system/user/upLoadUserPic',
        method: 'post',
        data: data
    })
}

export function getMsgCodeValidTime(params) {
    return request({
        url: '/system/getMsgCodeValidTime',
        method: 'get',
        params
    })
}

// 个人中心修改手机号
export function updateSelfPhone(data) {
    return request({
        url: '/system/user/updateSelfPhone',
        method: 'post',
        data: data
    })
}

// 个人中心修改邮箱
export function updateSelfEmail(data) {
    return request({
        url: '/system/user/updateSelfEmail',
        method: 'post',
        data: data
    })
}

// 个人中心更新信息
export function updateSelfBaseInfo(data) {
    return request({
        url: '/system/user/updateSelfBaseInfo',
        method: 'post',
        data: data
    })
}

// 密保问题发送手机验证码
export function sendPhoneVerCodeForQueryPwdAnswer(data) {
    return request({
        url: '/system/user/sendPhoneVerCodeForQueryPwdAnswer',
        method: 'post',
        data: data
    })
}

// 密保问题校验手机验证码
export function checkPhoneVerCodeForQueryPwdAnswer(data) {
    return request({
        url: '/system/user/checkPhoneVerCodeForQueryPwdAnswer',
        method: 'post',
        data: data
    })
}

// 密保问题发送邮箱验证码
export function sendEmailVerCodeForQueryPwdAnswer(data) {
    return request({
        url: '/system/user/sendEmailVerCodeForQueryPwdAnswer',
        method: 'post',
        data: data
    })
}

// 密保问题发送邮箱验证码
export function checkEmailVerCodeForQueryPwdAnswer(data) {
    return request({
        url: '/system/user/checkEmailVerCodeForQueryPwdAnswer',
        method: 'post',
        data: data
    })
}


